package com.pureut.system.service.impl;

import com.pureut.common.security.utils.DictUtils;
import com.pureut.system.api.domain.SysDictData;
import com.pureut.system.domain.dto.SysAuditDoneDto;
import com.pureut.system.domain.vo.SysAuditDoneVo;
import com.pureut.system.mapper.SysDaibanMapper;
import com.pureut.system.service.ISysDaibanService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @Description 审核待办实现类
 * @Param
 * @Date 22-12-09
 * @Author hl
 **/
@Service
public class SysDaibanServiceImpl implements ISysDaibanService {

    @Resource
    private SysDaibanMapper sysDaibanMapper;

    /**
     * 查询待办接口
     */
    @Override
    public List<SysAuditDoneDto> selectAuditDoneList(SysAuditDoneVo sysAuditDone) {
        List<SysDictData> dictList= DictUtils.getDictCache("sys_audit_state");
        Map<String, String> actualMap = dictList.stream().collect(Collectors.toMap(SysDictData::getDictValue, SysDictData::getDictLabel));
        List<SysAuditDoneDto> list = sysDaibanMapper.selectAuditDoneList(sysAuditDone);
        for (SysAuditDoneDto sy:
        list) {
            sy.setDoneStateDict(actualMap.get(String.valueOf(sy.getDoneState())));
        }
        return list;
    }


    /**
     * 新增待办接口
     */
    @Override
    public int insertDaiban(SysAuditDoneVo sysAuditDoneVo) {
        return sysDaibanMapper.insertDaiban(sysAuditDoneVo);
    }
}
